#ifndef __AEEPOLL_H__
#define __AEEPOLL_H__

#include <sys/epoll.h>
#include "ae.h"
#include "cacheAlloc.h"

//使用epoll时的结构
struct apiState
{
  apiState()
  :efd_(-1)
  ,ets_(nullptr)
  {}

  ~apiState()
  {
    efd_ = -1;
    tcfreeArray(epoll_event, ets_);
  }

  int efd_;
  struct epoll_event* ets_;
};

class Epoll
{
public:
  static apiState* EpollCreate(int setsize);
  static int AddEpoll(eventLoop* el, int fd, int mask);
  static int DelEpoll(eventLoop* el, int fd, int delmask);
  static int ModEpoll(eventLoop* el, int fd);
  static int WaitEpoll(eventLoop* el, int timeout);
};

#endif
